package cn.bby.tools.utils;

import cn.bby.tools.dialog.SingleCheckDialog;
import cn.hutool.core.util.StrUtil;
import com.intellij.BundleUtil;
import com.intellij.DynamicBundle;
import com.intellij.openapi.actionSystem.AnAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ResourceBundle;

/**
 * @author ben
 * @since 2025/9/24 22:26
 */
public class MessageUtil {
    private static final DynamicBundle BUNDLE =
            new DynamicBundle(MessageUtil.class, "messages/bby-messages");
    private static final Logger log = LoggerFactory.getLogger(MessageUtil.class);

    public static String getMessageSuffix(String key) {
        return getMessage(key,  ":");
    }

    public static String getMessage(String key, String suffix) {
        return getMessage(key) + suffix;
    }

    public static String getMessage(String key) {
        if (key == null || !BUNDLE.containsKey(key)) {
            log.warn("未找到对应的国际化文本：{}", key);
            return key;
        }
        return StrUtil.emptyToDefault(BUNDLE.getMessage(key), key);
    }
}
